/*
    This source file is part of GeNa project.
    Copyright © GeNa project 2008
    For the latest info, see http://code.google.com/p/genaproject/ or  http://lumpyproject.forums-rpg.com

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Foobar is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Foobar.  If not, see <http://www.gnu.org/licenses/>. */

#include "confwnd.h"
#include "property_manager.h"

ConfWindow::ConfWindow( wxWindow* parent ) : ConfWindowBase( parent )
{
    m_slider2->SetValue(propMgrInstance.getPropertyValue<float>("FreeCamera.mouseSensiX")*1000);
    m_slider1->SetValue(propMgrInstance.getPropertyValue<float>("FreeCamera.mouseSensiY")*1000);
    m_horSensiNum->SetLabel( wxString() << m_slider2->GetValue());
    m_vertSensiNum->SetLabel( wxString() << m_slider1->GetValue());


    m_slider4->SetValue(propMgrInstance.getPropertyValue<float>("FreeCamera.moveSensiX")*1000);
    m_slider3->SetValue(propMgrInstance.getPropertyValue<float>("FreeCamera.moveSensiY")*1000);
    m_slider31->SetValue(propMgrInstance.getPropertyValue<float>("FreeCamera.moveSensiUp")*1000);
    m_horMoveSensiNum->SetLabel( wxString() << m_slider4->GetValue());
    m_forMoveSensiNum->SetLabel( wxString() << m_slider3->GetValue());
    m_upMoveSensiNum->SetLabel( wxString() << m_slider31->GetValue());
}

void ConfWindow::OnThumbTrack(wxScrollEvent &event)
{
    wxString str;
    str << event.GetPosition();
    if( event.GetId() == ID_XSENSI)
        m_horSensiNum->SetLabel(str);
    else if( event.GetId() == ID_YSENSI)
        m_vertSensiNum->SetLabel(str);
    else if( event.GetId() == ID_XMOVESENSI)
        m_horMoveSensiNum->SetLabel(str);
    else if( event.GetId() == ID_YMOVESENSI)
        m_forMoveSensiNum->SetLabel(str);
    else if( event.GetId() == ID_UPMOVESENSI)
        m_upMoveSensiNum->SetLabel(str);

    OnThumbRelease(event);
}

void ConfWindow::OnThumbRelease(wxScrollEvent &event)
{
    if( event.GetId() == ID_XSENSI)
        propMgrInstance.setPropertyValue("FreeCamera.mouseSensiX", event.GetPosition()/1000.0f);
    else if( event.GetId() == ID_YSENSI)
        propMgrInstance.setPropertyValue("FreeCamera.mouseSensiY", event.GetPosition()/1000.0f);
    else if( event.GetId() == ID_XMOVESENSI)
        propMgrInstance.setPropertyValue("FreeCamera.moveSensiX", event.GetPosition()/1000.0f);
    else if( event.GetId() == ID_YMOVESENSI)
        propMgrInstance.setPropertyValue("FreeCamera.moveSensiY", event.GetPosition()/1000.0f);
    else if( event.GetId() == ID_UPMOVESENSI)
        propMgrInstance.setPropertyValue("FreeCamera.moveSensiUp", event.GetPosition()/1000.0f);
}
